@extends('admin.base.index')
@section('content')
<script type="text/javascript" src="{{ url('publics/jquery-1.8.3.min.js') }}"></script>

			<form action="" method="post" name="myform">
				<input type="hidden" name="_token" value="{{ csrf_token() }}">
				<input type="hidden" name="_method" value="delete">
			</form>

			<form action='{{ url("admin/comment")}}' method='get'>
			        <div class='media-body'>
			            姓名：<input type='text' class='form-control m-b-5' name='userid'>
			        </div>
			        <input type='submit' class='btn' value='搜索'>
			    </form>
	            <table class="table tile">
	                <thead>
	                    <tr>
	                        <th>id号</th>
	                        <th>用户</th>
	                        <th>评论内容</th>
	                        <th>发表时间</th>	                      
	                        <th>操作</th>
	                    </tr>
	                </thead>
	                <tbody>
	                @foreach($list as $v)
	                    <tr>
	                        <td>{{ $v->id}}</td>
	                        <td>{{ $v->userid}}</td>
	                        <td>{{ $v->content }}</td>
	                        <td>{{ date('Y-m-d H:i:s',$v->time)}}</td>
	                        <td>
		                        <a href="javascript:doDel({{$v->id}})">删除</a>|
								<a class="aid">回复</a>
	                        </td>
	                    </tr>
	                @endforeach   
	                </tbody>
	            </table>
	            
		            <form action='{{ url("admin/reply") }}' method='post' name="myforms" id="did" style="display:none">
		           		<input type="hidden" name="_token" value="{{ csrf_token() }}">
		           		<input type="hidden" name="pid" value="">
		           		<input type="hidden" name="userid" value="">
				        <div class='media-body'>
				            回复：<input type='text' class='form-control m-b-5' name='content'>
				        </div>
				        <input type='submit' class='btn' value="回复">
				    </form>
				
	            <script type="text/javascript">
					function doDel(id){
						if(confirm("是否删除？")){
							var a = document.myform;
							a.action = "{{ url('admin/comment') }}/"+id;
							a.submit();
						}
					}

					$(".aid").click(function(){
						$('#did').slideToggle();
						var id = $(this).parent().parent().children('td').eq(0).html();
						var uid = $(this).parent().parent().children('td').eq(1).html();
						//alert(id);
						$("input[name='pid']").val(id);
						$("input[name='userid']").val(uid);
						var aa = document.myforms;
						aa.action = "{{ url('admin/reply') }}";
														
					});


					// if ({{session()->has('status')}}) {
					// 	alert('回复成功');
					// };
					

					
				</script>
	{{ $list->appends($where)->links() }}
	       
@stop